from typing import Dict, Type

from .base import Adapter
from .primitive import PrimitiveAdapter
from .stl_vector import StdVectorAdapter

ADAPTER_REGISTRY: Dict[str, Type[Adapter]] = {
    PrimitiveAdapter.name: PrimitiveAdapter,
    StdVectorAdapter.name: StdVectorAdapter,
}

def get_adapter(name: str) -> Adapter:
    try:
        cls = ADAPTER_REGISTRY[name]
    except KeyError as exc:
        raise ValueError(f"Unknown adapter: {name}") from exc
    return cls()